﻿using System;
using System.Collections;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;

public class SendMail
{
    public static void RememberPassword(string mail, string contrasena)
    {
        System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
        msg.To.Add(mail);
        msg.From = new MailAddress("cold42012@gmail.com", "RAPSAC", System.Text.Encoding.UTF8);
        msg.Subject = "RAPSAC. Recordar contraseña";
        msg.SubjectEncoding = System.Text.Encoding.UTF8;
        msg.Body = "Estimado usuario, \n Le recordamos su contraseña. \nPara inciar sesión en RAPSAC debe utilizar la clave " + contrasena + "\n Un saludo";
        msg.BodyEncoding = System.Text.Encoding.UTF8;
        msg.IsBodyHtml = false;

        SmtpClient client = new SmtpClient();
        client.Credentials = new System.Net.NetworkCredential("cold42012@gmail.com", "cold42012");
        client.Port = 587;
        client.Host = "smtp.gmail.com";
        client.EnableSsl = true;
        try
        {
            client.Send(msg);
        }
        catch (System.Net.Mail.SmtpException ex)
        {
            throw ex;
        }
    }
}